<template>
  <div>
    <van-nav-bar
      title="登录"
      right-text="去注册"
      left-arrow
      @click-left="$router.back()"
      @click-right="$router.push('/regiest')"
    />

    <van-form @submit="onSubmit">
      <van-field
        v-model="phone"
        name="phone"
        label="手机号"
        placeholder="手机号"
        :rules="[{ required: true, message: '请填写手机号' }]"
      />
      <van-field
        v-model="password"
        type="password"
        name="password"
        label="密码"
        placeholder="密码"
        :rules="[{ required: true, message: '请填写密码' }]"
      />
      <div style="margin: 16px">
        <van-button round block type="info" native-type="submit"
          >提交</van-button
        >
      </div>
    </van-form>
  </div>
</template>

<script>
import { Login } from "./util/axios";
import { Toast } from "vant";
export default {
  data() {
    return {
      phone: "",
      password: "",
    };
  },
  methods: {
    onSubmit(value) {
        // console.log();
      Login(value).then((res) => {
        if (res.code == 200) {
          Toast.success(res.msg)
        //   console.log(res);
        //   return
          sessionStorage.setItem("userInfo",JSON.stringify(res.list));
          this.$router.push("/home");
        }
      });
    },
  },
};
</script>

<style>
</style>